import request from '@/axios';
import {baseUrl} from '@/config/env';

function pageMyBusiness(data) {
    return request({
            url: baseUrl + '/startActApi/pageMyBusiness',
            method: 'get',
            params: data
        }
    )
}

function getStartProcDefDetail(procDefKey) {
    return request({
            url: baseUrl + '/startActApi/getStartProcDefDetail/' + procDefKey,
            method: 'get',

        }
    )
}

function startApply(procDefKey, data) {
    return request({
            url: baseUrl + '/startActApi/startApply/' + procDefKey,
            method: 'post',
            data: data
        }
    )
}

/**
 * 取消流程
 * @param actBusinessId 流程业务id
 * @param reason 取消原因
 * @returns {AxiosPromise}
 */
function cancelApply(actBusinessId, reason) {
    let data = {}
    data.actBusinessId = actBusinessId;
    data.reason = reason;
    return request({
            url: baseUrl + '/startActApi/cancelApply',
            method: 'post',
            data: data
        }
    )
}

/**
 * 获取流程实例详情
 * @param actBusinessId
 */
function getActInsDetail(actBusinessId) {
    return request({
            url: baseUrl + '/startActApi/getActInsDetail/' + actBusinessId,
            method: 'get',
        }
    )
}

/**
 * 删除草稿流程
 * @param actBusinessId 业务id
 * @returns {AxiosPromise}
 */
function deleteActById(actBusinessId) {
    return request({
            url: baseUrl + '/startActApi/deleteActById/' + actBusinessId,
            method: 'delete',
        }
    )
}

const startActApi = {
    pageMyBusiness,
    getStartProcDefDetail,
    getActInsDetail,
    startApply,
    cancelApply,
    deleteActById,
}
export default startActApi
